package com.yb.xczx.security.resource.config;

import com.yb.core.model.WhiteListProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
import org.springframework.security.oauth2.server.resource.introspection.NimbusOpaqueTokenIntrospector;
import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.util.CollectionUtils;

//@Configuration

@Slf4j
@ComponentScan("com.yb.xczx.security.resource")
public class Oauth2OpaqueTokenConfig extends AbstractOauth2TokenSecurityConfig{


    public Oauth2OpaqueTokenConfig(){
        log.info("Oauth2OpaqueTokenConfig");
    }

    @Override
    protected void resourceServerConfig(HttpSecurity http) throws Exception {
        http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::opaqueToken);
    }

    @Bean
    OpaqueTokenIntrospector opaqueTokenIntrospector(){
        return new CustomAuthoritiesOpaqueTokenIntrospector();
    }
}
